package com.farm.learn.enums;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.collections.map.HashedMap;

import com.farm.parameter.FarmParameterService;

/**课程等级，有默认值也可通过数据字典自定义
 * @author Wd
 *
 */
public class ClassDifficulty {

	@SuppressWarnings("unchecked")
	public static Map<String, String> getMap() {
		Map<String, String> dics = FarmParameterService.getInstance().getDictionary("WLP_CLASS_DIFFICULTY");
		if (dics == null || dics.size() <= 0) {
			dics = new HashedMap();
			// "1:入门,2:初级,3:中级,4:高级"
			dics.put("1", "入门");
			dics.put("2", "初级");
			dics.put("3", "中级");
			dics.put("4", "高级");
		}
		return dics;
	}

	public static List<Entry<String, String>> getList() {
		List<Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>();
		for (Entry<String, String> node : getMap().entrySet()) {
			list.add(node);
		}
		list.sort(new Comparator<Entry<String, String>>() {
			@Override
			public int compare(Entry<String, String> o1, Entry<String, String> o2) {
				return o1.getKey().compareTo(o2.getKey());
			}
		});
		return list;
	}
}
